<%--
  Created by IntelliJ IDEA.
  User: 22770
  Date: 2023/1/9
  Time: 11:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>添加摇号用户</title>
    <link type="text/css" rel="stylesheet" href="../../../css/raojt/day0109/addUser.css"/>
    <script type="text/javascript" src="../../../js/raojt/day0109/User.js"></script>
    <!-- 引用jQuery外部文件 -->
    <script type="text/javascript" src="../../../js/raojt/day0109/jquery-3.6.3.js"></script>
    <!-- 引用自定义的js文件 -->
    <!-- <script type="text/javascript" src="js/addUser.js"></script> -->
    <script type="text/javascript">
        function btnSub(){
            document.forms[0].action="addUserController.jsp";
        }
    </script>
</head>
<body>
<div class="population">
    <div class="top">
        <h1>添加摇号用户</h1>
    </div>
    <form method="post" action="addUserController.jsp">
    <div class="middle">
        <p id="errLoginInfo"></p><br />
        <span>用户姓名 ：</span>
        <input name="putName" id="putName" type="text" value=""/>*<br /><br />
        <span>手机号码 ：</span>
        <input name="putPhone" id="putPhone" type="text" value=""/>*<br />
    </div>
    <div class="last">
        <button onclick="btnSub();" class="checkUser">提交</button>
        <button onclick="location.href='lottery.jsp'">返回</button>
    </div>
    </form>
</div>
</body>
<script>
    $(function(){
        /* jQuery绑定事件 */
        /* 使用类class选择器 */
        // $(".checkUser").click(function(){
        // $("#errLoginInfo").html("请填写完整的用户信息！！！")
        // $("#errLoginInfo").css("color","red")
        // });

        //添加数据单继事件

        /* 使用后代选择器 + 元素过滤筛选*/
        $(".last button:first").click(function(){
            var $inputs = $("[name='input']");
            var num = "";
            //each 语法：$(selector).each(function(index,element))
            //$.each(function(){});
            $inputs.each(function(i){
                if($($inputs[i].val == "")){
                    $("#errLoginInfo").html("请填写完整的用户信息！！！");
                    $("#errLoginInfo").css("color","red");
                    num ++;
                    return;
                }
            });
            if(num == ""){
                $("#errLoginInfo").html(" ");
            }
        });
    });
</script>
</html>
